package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Name      string `gorm:"type:varchar(30);comment:用户名称"`
	ClassName string `gorm:"type:varchar(30);comment:用户购买的课程名称"`
	Num       int    `gorm:"type:int;comment:用户购买的数量"`
}

func (User) TableName() string {
	return "user"
}

func (u *User) Buy() error {
	return DB.Create(&u).Error
}
